//
//  InstallBoxCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/28.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "InstallBoxCell.h"

@interface InstallBoxCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UITextField *nameField;
@property (nonatomic, strong) UITextField *capacityField;
@property (nonatomic, strong) UITextField *countField;

@end

@implementation InstallBoxCell

+ (instancetype)InstallBoxCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"InstallBoxCell";
    InstallBoxCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[InstallBoxCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenW - 30, 183)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.nameField = [[UITextField alloc] initWithFrame:CGRectMake(10, 0, self.bgView.nim_width - 20, 60)];
        self.nameField.textColor = HexColor(0x2B2C44);
        self.nameField.font = [UIFont systemFontOfSize:14];
        self.nameField.textAlignment = NSTextAlignmentRight;
        self.nameField.userInteractionEnabled = NO;
        self.nameField.text = @"请选择";
        UILabel *nameLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, [FactoryMethod sizeWithText:@"选择货物" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].width, [FactoryMethod sizeWithText:@"选择货物" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].height)];
        nameLab.font = [UIFont systemFontOfSize:14];
        nameLab.textColor = HexColor(0x2B2C44);
        nameLab.text = @"选择货物";
        self.nameField.leftView = nameLab;
        self.nameField.leftViewMode = UITextFieldViewModeAlways;
        UIImageView *arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(6, (self.nameField.nim_height - 18) * 0.5, 18, 18)];
        arrowImgView.image = [UIImage imageNamed:@"icon_arrow_down"];
        UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 24, self.nameField.nim_height)];
        [rightView addSubview:arrowImgView];
        self.nameField.rightView = rightView;
        self.nameField.rightViewMode = UITextFieldViewModeAlways;
        [self.bgView addSubview:self.nameField];
        
        UILabel *line1 = [[UILabel alloc] initWithFrame:CGRectMake(self.nameField.nim_left, self.nameField.nim_bottom, self.nameField.nim_width, 1)];
        line1.backgroundColor = HexColor(0xF2F2F5);
        [self.bgView addSubview:line1];
        
        self.capacityField = [[UITextField alloc] initWithFrame:CGRectMake(10, line1.nim_bottom, self.bgView.nim_width - 20, 60)];
        self.capacityField.textColor = HexColor(0x2B2C44);
        self.capacityField.font = [UIFont systemFontOfSize:14];
        self.capacityField.textAlignment = NSTextAlignmentRight;
        self.capacityField.placeholder = @"请输入";
        UILabel *capacityLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, [FactoryMethod sizeWithText:@"收容数" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].width, [FactoryMethod sizeWithText:@"收容数" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].height)];
        capacityLab.font = [UIFont systemFontOfSize:14];
        capacityLab.textColor = HexColor(0x2B2C44);
        capacityLab.text = @"收容数";
        self.capacityField.leftView = capacityLab;
        self.capacityField.leftViewMode = UITextFieldViewModeAlways;
        self.capacityField.keyboardType = UIKeyboardTypeDecimalPad;
        [self.bgView addSubview:self.capacityField];
        
        UILabel *line2 = [[UILabel alloc] initWithFrame:CGRectMake(self.capacityField.nim_left, self.capacityField.nim_bottom, self.capacityField.nim_width, 1)];
        line2.backgroundColor = HexColor(0xF2F2F5);
        [self.bgView addSubview:line2];
        
        self.countField = [[UITextField alloc] initWithFrame:CGRectMake(10, line2.nim_bottom, self.bgView.nim_width - 20, 60)];
        self.countField.textColor = HexColor(0x2B2C44);
        self.countField.font = [UIFont systemFontOfSize:14];
        self.countField.textAlignment = NSTextAlignmentRight;
        self.countField.placeholder = @"请输入";
        UILabel *countLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, [FactoryMethod sizeWithText:@"货物数量" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].width, [FactoryMethod sizeWithText:@"货物数量" font:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(0, 0)].height)];
        countLab.font = [UIFont systemFontOfSize:14];
        countLab.textColor = HexColor(0x2B2C44);
        countLab.text = @"货物数量";
        self.countField.leftView = countLab;
        self.countField.leftViewMode = UITextFieldViewModeAlways;
        self.countField.keyboardType = UIKeyboardTypeDecimalPad;
        [self.bgView addSubview:self.countField];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
